<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
            list-style: none;
        }
        body{
            background-color: rgb(189, 189, 189);
        }
        #app{
            width: 1500px;
            margin: 0 auto;
        }
        .i{
            width: 300px;
            height: 45px;
            margin-top: 10px;
            margin-bottom: 20px;
            font-size: 20px;
        }
        .b{
            width: 100px;
            height: 50px;
            margin-top: 10px;
            background-color: gold;
            font-size: 20px;
        }
        ul{
            font-size: 30px;
            color: #909;
        }
        .bb{
            width: 40px;
            height: 30px;
            background: greenyellow;
            color: #000 ;
        }
        .ii{
            width: 20px;
            height: 20px;
        }
        .dd{
            margin-left: 610px;
        }
        i{
            margin-left:450px;
            margin-right: 20px;
            font-size: 30px;
            font-weight: bolder;
        }
    </style>
</head>
<body>
    <div id="app">
         <i>ToDoList</i> 
        <input class="i" v-model="val" type="text" placeholder="添加ToDo">
        <button class="b" @click="add">添加</button>

        <div class="dd">
            <h2>正在进行 ------ {{len}}</h2>
            <ul>
                <li v-for="(item,index) in arr" v-show="!item.checked">
                    <input v-model="item.checked" type="checkbox" class="ii">
                    {{item.val}}
                    <button class="bb" @click="arr.splice(index,1)">删除</button>
                </li>
            </ul>

            <h2>已经完成 ------ {{arr.length - len}}</h2>
            <ul>
                <li v-for="(item,index) in arr" v-show="item.checked" >
                    <input v-model="item.checked" type="checkbox" class="ii">
                    {{item.val}}
                    <button class="bb" @click="arr.splice(index,1)">删除</button>
                </li>
            </ul>
        </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script>
        new Vue({
            el:"#app",
            data:{
                val:"",
                arr:[]
            },
            methods:{
                add(){
                    this.arr.push({
                        val:this.val,
                        checked:false
                    })
                    this.val = ""
                },
            },
            computed:{
                len(){
                    return this.arr.filter((item)=>{
                        return item.checked === false
                    }).length
                }
            }
        })
    </script>
</body>
</html>